/*
 * Copyright 2008-2015 Arsen Chaloyan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef WHISPER_ASR_H
#define WHISPER_ASR_H

#include "apr_pools.h"
#include "apt_string.h"

/** Whisper ASR configuration */
typedef struct whisper_asr_config_t {
    apt_str_t api_url;          /* Whisper API URL */
    apt_str_t auth_token;       /* Authorization token */
    apt_str_t model;            /* Model name (default: whisper-1) */
    apt_str_t response_format;  /* Response format (default: json) */
} whisper_asr_config_t;

/** Initialize Whisper ASR configuration */
whisper_asr_config_t* whisper_asr_config_create(apr_pool_t *pool);

/** Load Whisper ASR configuration from file */
apt_bool_t whisper_asr_config_load(const char *config_file, whisper_asr_config_t *config, apr_pool_t *pool);

/** Test configuration loading */
apt_bool_t whisper_asr_config_test(const char *config_file, apr_pool_t *pool);

/** Convert PCM file to WAV format */
apt_bool_t pcm_to_wav(const char *pcm_file_path, const char *wav_file_path,
                     int sample_rate, apr_pool_t *pool);

/** Call Whisper ASR API to transcribe audio */
apt_bool_t whisper_asr_transcribe(const char *wav_file_path,
                                 whisper_asr_config_t *config,
                                 apt_str_t *transcription,
                                 apr_pool_t *pool);

/** Generate NLSML result from transcription */
apt_bool_t generate_nlsml_result(apt_str_t *channel_id,
                                 const apt_str_t *transcription,
                                 const char *session_info,
                                apt_str_t *nlsml_result,
                                apr_pool_t *pool);

#endif /* WHISPER_ASR_H */